package com.example.tests;

import org.junit.Test;
import static org.junit.Assert.*;

import com.example.tests.pages.LoginPage;
import com.example.tests.pages.MyPageFactory;

public class MyProfileTest extends BrowserTest {
	private boolean result;

	@Test
	public void testCheckProfile() {
		result = MyPageFactory.getPage(driver, LoginPage.class)
					.login(admin)
					.goProfilePage()
					.isUsernameMatches(admin.getUsername());
	    assertTrue(result);
	}
	@Test
	public void testCheckProfileEmail() {
		result = MyPageFactory.getPage(driver, LoginPage.class)
				.login(admin)
				.goProfilePage()
				.isEmailMatches(admin.getEmail());	    
	    assertTrue(result);
	}
	@Test
	public void testCheckProfileRole() {
		result = MyPageFactory.getPage(driver, LoginPage.class)
				.login(admin)
				.goProfilePage()
				.isRoleMatches(admin.getRole());
		
	    assertTrue(result);
	}
	@Test
	public void testChangePassword() {
		MyPageFactory.getPage(driver, LoginPage.class)
				.login(admin)
				.goProfilePage()
				.setPassword("qwerty12")
				.logout();
		result = MyPageFactory.getPage(driver, LoginPage.class)		
					.loginSuccesfullAs(admin.getUsername(),"qwerty12")
					.IsLoginSuccessfull();
	    assertTrue(result);
	    MyPageFactory.getPage(driver, LoginPage.class)
		    	.loginSuccesfullAs("admin", "qwerty12")
		    	.goProfilePage()
	    		.setPassword(admin.getPassword())
	    		.logout();
	}
}
